<!DOCTYPE html>
<html>
<head>
<title>发表博文</title>

<meta name="content-type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../editor.md/css/editormd.min.css" />

<script type="text/javascript" charset="UTF-8"
	src="../../../easyui/jquery.min.js"></script>
<link rel="stylesheet" id="easyuiTheme"
	href="../../../easyui/themes/default/easyui.css" type="text/css"></link>
<link rel="stylesheet" id="easyuiTheme"
	href="../../../easyui/themes/icon.css" type="text/css"></link>
<link rel="stylesheet" id="easyuiTheme"
	href="../../../easyui/themes/color.css" type="text/css"></link>
<script type="text/javascript"
	src="../../../easyui/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="../../../easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="../../../style/syExtIcon.css"
	type="text/css"></link>
<link rel="stylesheet" href="../../../style/syExtCss.css"
	type="text/css"></link>
<script type="text/javascript" src="../../../js/ExtEasyui.js"></script>
<script type="text/javascript" src="../../../js/Extjs.js"></script>
<script src="../../../editor.md/editormd.min.js"></script>
<script type="text/javascript" src="../../../adminjs/postAdd_md.js"></script>
<script type="text/javascript" src="../../../adminjs/postAdd_upload.js"></script>
<script type="text/javascript">
	var postsadd_submitForm = function(dialog, postsDataGrid, p) {
		if ($('posts_addForm').form('validate')) {
			var fields = $('#posts_addForm').serializeArray();
			var o = {}; //声明一个对象
			$.each(fields, function(index, field) {
				// obj[field.name] = field.value; //通过变量，将属性值，属性一起放到对象中
				if (o[this.name] !== undefined) {
					if (!o[this.name].push) {
						o[this.name] = [ o[this.name] ];
					}
					if (undefined != this.value && '' != this.value) {
						o[this.name].push(this.value);
					}
				} else {
					if (undefined != this.value && '' != this.value) {
						o[this.name] = this.value;
					}
				}
			})

			$.ajax({
				type : "POST",
				url : "/posts/add",
				contentType : "application/json", //必须有
				dataType : "json", //表示返回值类型，不必须
				data : JSON.stringify(o),
				success : function(j) {
					postsDataGrid.datagrid('reload');
					dialog.dialog('destroy');
					p.messager.show({
						title : '提示',
						msg : j.msg,
						timeout : 5000,
						showType : 'slide'
					});
				},
				error : function(j) {
					p.messager.show({
						title : '提示',
						msg : j.msg,
						timeout : 5000,
						showType : 'slide'
					});
				}
			});
		}
	};
</script>
</head>

<body>
	<form id="posts_addForm" method="post">
		<input id="post_id" type="hidden" name="id" value="{posts.id ?: ''}" />
		<input id="post_pic" type="hidden" name="postPic" value="" />
		 <strong>标题：</strong><input
			name="postTitle" size="100" value="{posts.postTitle ?: ''}"><br />
		<strong>分类：</strong><input name="types" size="50" maxlength="20"
			value="{posts.types ?: ''}"><br /> <strong>描述：</strong>
		<textarea name="description" cols="80" rows="3">{posts.description ?: ''}</textarea>
		<br /> <strong>文章内容：</strong>
		<div id="test-editormd">
			<textarea name="content" class="editormd-markdown-textarea"
				name="test-editormd-markdown-doc" style="display: none;">{posts.content ?: ''}</textarea>
		</div>
		<strong>首图：</strong><input type="file" name="file" id="file_upload" />
		<img id="show_file_upload" alt="" style="width: 200px; height: 200px"
			src="{posts.postPic ?: '/images/weirweiwei.png'}"> <br />
	</form>
</body>
</html>
